﻿@using System.Web.Mvc;

@model IEnumerable<Core.Models.Post>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout_Guest.cshtml";
}
@helper Truncate(string input, int length)
{
    input = Server.HtmlDecode(input);
    if (input.Length <= length)
    {
        @Html.Raw(input)
    }
    else
    {
        @Html.Raw(input.Substring(0, length)) <text>...</text>
    }
}
@foreach (var item in Model)
{ 
    <div class="panel panel-success">
        <div class="panel-heading">
            <h3 class="panel-title">
                @Html.ActionLink(@item.Title, "Details", "Home", new { id = @item.Id }, "")</h3>
        </div>
        <div class="panel-body">
            <div class="panel-body-createddate">
                @Html.DisplayFor(model => item.CreatedDate)
            </div>
            <div class="panel-body-content">
                @Truncate(item.Content, 500)
            </div>
        </div>
    </div>
}
<div id="older_newer_post">
    <div id="older_post">
        @if (ViewBag.CurrentSkipAt + ViewBag.PageSize < ViewBag.TotalRecords)
        {
            @Html.ActionLink("<< Older Post", "Index", "Home", new { skipAt = ViewBag.CurrentSkipAt + ViewBag.PageSize }, "")
        }
    </div>
    <div id="newer_post">
        @if (ViewBag.CurrentSkipAt - ViewBag.PageSize >= 0)
        {
            @Html.ActionLink("Newer Post >>", "Index", "Home", new { skipAt = ViewBag.CurrentSkipAt - ViewBag.PageSize }, "")
        }
    </div>
</div>
